# 测试高德地图API调用
$apiKey = "6b57d674ba96db7c6e4defc6a601c088"
$location = "116.4074,39.9042" # 北京市中心
$radius = "2000"
$keywords = "美食"

$url = "https://restapi.amap.com/v3/place/around?key=$apiKey&keywords=$keywords&location=$location&radius=$radius&offset=5&page=1&extensions=base&output=json&types=050000"

Write-Host "🔍 测试高德地图API调用..." -ForegroundColor Green
Write-Host "URL: $url" -ForegroundColor Yellow

try {
    $response = Invoke-RestMethod -Uri $url -Method Get
    
    Write-Host "✅ API调用成功!" -ForegroundColor Green
    Write-Host "状态: $($response.status)" -ForegroundColor Cyan
    Write-Host "信息: $($response.info)" -ForegroundColor Cyan
    Write-Host "POI数量: $($response.pois.Count)" -ForegroundColor Cyan
    
    if ($response.pois.Count -gt 0) {
        Write-Host "📍 前3个POI:" -ForegroundColor Magenta
        for ($i = 0; $i -lt [Math]::Min(3, $response.pois.Count); $i++) {
            $poi = $response.pois[$i]
            Write-Host "  $($i+1). $($poi.name) - $($poi.address)" -ForegroundColor White
        }
    }
    
    # 保存完整响应到文件
    $response | ConvertTo-Json -Depth 10 | Out-File "gaode-api-response.json" -Encoding UTF8
    Write-Host "📄 完整响应已保存到 gaode-api-response.json" -ForegroundColor Yellow
    
} catch {
    Write-Host "❌ API调用失败: $($_.Exception.Message)" -ForegroundColor Red
} 